package leetcode.offer_two_special.dp;

import java.util.Arrays;

/**
 * @author mazouri
 * @create 2021-09-25 21:56
 */
public class _377_combinationSum4_dp {
    public int combinationSum4(int[] nums, int target) {
        //dp[i]代表target为i的所有组合个数
        int[] dp = new int[target + 1];
        dp[0] = 1;

        for (int i = 1; i <= target; i++) {
            for (int j = 0; j < nums.length; j++) {
                if (i - nums[j] >= 0) {
                    dp[i] += dp[i - nums[j]];
                }
            }
        }
        return dp[target];
    }
}
